package com.easybuilder.common.enums;

public enum WSMessageType { // websocket消息类型枚举
    PING_PONG(0, "ping-pong心跳机制"),
    BIND_USER_CHANNEL(100, "绑定用户id与通道"),
    SEND_SINGLE_MESSAGE(200, "发送单人聊天消息"),
    SEND_GROUP_MESSAGE(300, "发送群聊消息"),
    OFFLINE_MESSAGE_PUSH(400, "离线消息推送"),
    MESSAGE_RECEIVED_SUCCESS(500, "消息接收成功确认"),
    MESSAGE_READ_SUCCESS(600, "已读取"),
    MESSAGE_BACK(700, "消息撤回");

    private Integer value;
    private String description;

    WSMessageType(Integer value, String description) {
        this.value = value;
        this.description = description;
    }

    public static String getName(Integer type) {
        WSMessageType[] values = WSMessageType.values();
        for (WSMessageType wsMessageType : values) {
            if (wsMessageType.value.equals(type)) {
                return wsMessageType.name();
            }
        }
        return null;
    }

    public Integer value() {
        return this.value;
    }

}
